package com.asp.aspchain.tstaccount.controller;

import com.asp.aspchain.core.util.AjaxResult;
import com.asp.aspchain.tstaccount.constants.ErrorCode;
import com.asp.aspchain.tstaccount.service.EoaCrtaccService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/account")
public class TstCrtController {
	
	private final static Logger logger = Logger.getLogger(TstCrtController.class);

	@Autowired
    private EoaCrtaccService eoaCrtaccService;
	
	@PostMapping("/eoa/crtaccount")
	public AjaxResult eoaCrtaccount(@RequestBody String json) {
		
		logger.info("=============eoa创建账户接口开始=============");
    	//接受前端请求记录内部日志
    	AjaxResult ajaxResult = new AjaxResult();
    	try{
    		ajaxResult = eoaCrtaccService.eoaCrtaccount(json);
    	}catch (Exception e) {
    		logger.error("eoaCrtaccount接口错误："+e.getMessage());
    		ajaxResult.setTips("系统内部错误");
    		ajaxResult.setMessage("系统内部错误");
    		ajaxResult.setStatus(ErrorCode.INTERNAL_ERROR);
		}
    	logger.info("=============eoa创建账户接口结束=============");
    	return ajaxResult;
	}
}
